package controleur;

import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JOptionPane;

import vue.*;
/**
 * 
 * @author Plancq Charlotte, Lanvin Kévin, Darras Raphael
 *
 *
 */
public class ModifCollectionListener extends KeyAdapter implements ActionListener {
	private AffichageGlobal a;
	private AffichageModifCollection amc;
	private int index;


	public ModifCollectionListener(AffichageGlobal a, AffichageModifCollection amc, int index) {
		this.a=a;
		this.index=index;
		this.amc=amc;
	}

	public void actionPerformed(ActionEvent arg0) {
		JButton b = (JButton) arg0.getSource();
		if (b.getText().equals("Modifier la collection !")) {
			boolean bool = a.getTraitement().setNomCollection(index, amc.getNom());
			if (bool)
				JOptionPane.showMessageDialog(amc, "La collection a bien ete modifiee !");
		}
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		if(arg0.getKeyCode()==KeyEvent.VK_ENTER){
			boolean bool = a.getTraitement().setNomCollection(index, amc.getNom());
			if (bool)
				JOptionPane.showMessageDialog(amc, "La collection a bien ete modifiee !");
		}

	}
}

